package com.ayoka.parenting.ui.login;

import com.ayoka.parenting.bean.BaseResponse;
import com.ayoka.parenting.bean.NVCBean;
import com.ayoka.parenting.http.API;
import com.ayoka.parenting.http.HttpBeanInterceptCallback;
import com.ayoka.parenting.interf.CallbackUtil;
import com.ayoka.parenting.interf.RequestCallback;
import com.ayoka.parenting.mvp.BasePresenter;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: LoginModel&.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class LoginModel implements LoginContract.Model{

    @Override
    public void sendVerifyCode(BasePresenter presenter, String token, String mobile, final RequestCallback<BaseResponse<NVCBean>> callback) {
        API.sendVerifyCode(presenter, token, mobile, new HttpBeanInterceptCallback<BaseResponse<NVCBean>>() {
            @Override
            public void onSuccess(BaseResponse<NVCBean> response) {
                CallbackUtil.notifySuccess(callback, response);
            }

            @Override
            public void onFailure(int errorCode, String errorMessage) {
                CallbackUtil.notifyFailure(callback, errorCode, errorMessage);
            }
        });
    }

    @Override
    public void login(BasePresenter presenter, String token, String mobile, String verifyCode, final RequestCallback<BaseResponse<NVCBean>> callback) {
        API.LoginWithCellphone(presenter, token, mobile, verifyCode, new HttpBeanInterceptCallback<BaseResponse<NVCBean>>() {
            @Override
            public void onSuccess(BaseResponse<NVCBean> response) {
                CallbackUtil.notifySuccess(callback, response);
            }

            @Override
            public void onFailure(int errorCode, String errorMessage) {
                CallbackUtil.notifyFailure(callback, errorCode, errorMessage);
            }
        });
    }
}
